package main

import "fmt"

func main(){
	arr := []int{123,421,54,75,324,86,65,5}
	fmt.Println(bu(arr))
	fmt.Println(sort_quick(arr))
}

func bubble_sort(arr []int ) []int {
	n := len(arr)
	for i := 0; i< n; i++{
		for j := 0; j < n - i - 1; j++{
			if arr[j] > arr[j+1]{
				arr[j], arr[j+1] = arr[j+1], arr[j]
			}
		}
	}
	return arr
}

func sort_quick(arr []int) []int{
	if len(arr) <= 1{
		return arr
	}
	pivot := arr[len(arr) / 2]
	middle := make([]int, 0)
	left := make([]int, 0)
	right := make([]int, 0)
	for _, i := range(arr){
		switch {
		case i > pivot:
			right = append(right, i)
		case i == pivot:
			middle = append(middle, i)
		case i < pivot:
			left = append(left, i)
		}
	}
	res := append(sort_quick(left), middle...)
	res = append(res, right...)
	return res
}